<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<meta HTTP-EQUIV="pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<meta HTTP-EQUIV="expires" CONTENT="0">
<title>_${customer.customerName}_作业批次</title>


<script type="text/javascript">
  $(function() {
		$("#queryForm").validate();
		$("#_fromDate").datepicker({ format:'yyyy-mm-dd'});
		$("#_toDate").datepicker({ format:'yyyy-mm-dd'});
  });
  
  function ajaxAreaGroup(item) {
		customerCode=item.value;
		$.ajax({
					type : 'post',
					url : '${ctx}/areaGroup/ajaxAreaGroup',
					data : 'customerCode=' + customerCode,
					dataType : 'json',
					success : function(data) {
					  var tempString="";
						if (data.status == "1") {
							$.each(data.content,function(i){
							    tempString+="<option value="+data.content[i].groupCode+">"+data.content[i].groupName;
							});
						} else if (data.status == "2") {
							$.each(data.content.restAreaGroupDtos,function(i){
							    tempString+="<option value="+data.content.restAreaGroupDtos[i].areagroupCode+">"+data.content.restAreaGroupDtos[i].areagroupName;
							});
						}else {
							alert(data.content);
						}
                    $("#_warehouseCode").html(tempString);
                    $("#_warehouseCode").trigger("chosen:updated");
					},
					error : function() {
						alert("获取信息错误！");
					}
				});
	}
  function ajaxHomeAreaGroup(item) {
		customerCode=item.value;
		$.ajax({
					type : 'post',
					url : '${ctx}/areaGroup/ajaxHomeAreaGroup',
					data : 'customerCode=' + customerCode,
					dataType : 'json',
					success : function(data) {
					  var tempString="";
						if (data.status == "1") {
							$.each(data.content,function(i){
							    tempString+="<option value="+data.content[i].groupCode+">"+data.content[i].groupName;
							});
						}else {
							alert(data.content);
						}
                  $("#areaGroupCodeSingle").html(tempString);
                  $("#areaGroupCodeSingle").trigger("chosen:updated");
					},
					error : function() {
						alert_message("系统错误！","请检查网络连接是否正常！","error",10000);
					}
				});
	}

</script>
</head>

<body>

    <form class="form-search" id="queryForm" method="post" action="${ctx}/focusBatchTask/queryWorkBatch" style="margin-top: 10px;">
	<table class="table table-striped table-bordered table-condensed" style="margin-top: 0px;">
		<thead>
			<th style="vertical-align: middle; color: white; " colspan="1" bgcolor="#999">条件查询</th>
		</thead>
		<tr>
		   <td class="controls-row">
		      <label style="margin-left: 10px;"><b>商家:</b></label>
				<select class="input-small required"  id="_customerCode" name="_customerCode"  value="${param._customerCode}" style="width: 95px;" onchange="ajaxHomeAreaGroup(this);ajaxAreaGroup(this);">
						<c:forEach items="${customers}" var="o">
							<option value="${o.customerCode}" <c:if test="${param._customerCode eq o.customerCode }">selected=selected</c:if>>${o.customerName}</option>
						</c:forEach>
				</select> 
 			 	<label style="margin-left: 10px;"><b>仓库:</b></label> 
 				 <select  name="_warehouseCode"  id="_warehouseCode" value="${param._warehouseCode}"  class="input-small" style="width: 120px;"> 
 					<c:if test="${wmList eq null }">
							<c:forEach items="${object.restAreaGroupDtos}" var="obj">
								<option value="${obj.areagroupCode}" <c:if test="${areaGroupCode eq obj.areagroupCode}">selected</c:if>> ${obj.areagroupName}
								</option>
							</c:forEach>
				   </c:if>
				   <c:if test="${object eq null }">
				     <c:forEach items="${wmList}" var="wm">
						<option value="${wm.groupCode}" <c:if test="${param._warehouseCode eq wm.groupCode}">selected=selected</c:if> >${wm.groupName}</option>
					  </c:forEach>
				   </c:if>
 				</select>
				 <label><b>网点:</b></label>
						<select name="_areaGroupCode" class="input-small" style="width: 160px;" id="areaGroupCodeSingle">
							<c:forEach items="${areaGroups}" var="obj">
								<option value="${obj.groupCode}"
									<c:if test="${areaGroupCode eq obj.groupCode}">selected</c:if>>${obj.groupName}
								</option>
							</c:forEach>
						</select>
				 <label style="margin-left: 10px;"><b>类型:</b></label>
				 <select class="input-small"  id="_batchType" name="_batchType" style="width: 70px;">
				        <option value="" <c:if test="${param._pickType eq ''}">selected="selected"</c:if>>全选</option>
				        <option value="single" <c:if test="${param._pickType eq 'single'}">selected="selected"</c:if>>单件</option>
				        <option value="multiple" <c:if test="${param._pickType eq 'multiple'}">selected="selected"</c:if>>多件</option>
				 </select>
			 
				
			    
		   </td>
		</tr>
		<tr>
		<td>
			<label style="margin-left: 10px;"><b>时间：</b></label> 
			 	<input type="text" name="_fromDate" id="_fromDate"  class="span2" value="${param._fromDate}">
			 	<label><b>至：</b></label> 
			 	<input type="text" name="_toDate" id="_toDate" class="span2" value="${param._toDate}">
			 	
		   
		  <button class="btn btn-info" type="submit" style="margin-left: 10px;">搜索</button>
			
		</td>
		</tr>
		
	</table>
	 </form>
	
	
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr>
			    <th>序号</th>
			    <th>仓库编码</th>
			    <th>批次编号</th>
			    <th>批次类型</th>
			   
			    <th>订单数量</th>
			    <th>创建人</th>
			    <th>创建时间</th>
			    <th>批次状态</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
		<c:choose>
<c:when test="${batchList eq null}">
<c:forEach items="${pageBatchList.content}" var="batch" varStatus="i">
			<tr>
			  <td>${i.count}</td>
			  <td>${batch.warehouseCode}</td>
			  <td>${batch.batchTaskCode}</td>
			  <td>
			    <c:if test="${batch.type eq 'single'}">
			               单件
			    </c:if>
			     <c:if test="${batch.type eq 'multiple'}">
			               多件
			    </c:if>
			  </td>
			  
			  <td>${batch.ordenoQty}</td>
			  <td>${batch.username}</td>
			  <td>${batch.createDate}</td>
			  <td>
			    <c:if test="${batch.status eq 'pending'}">
			           <span class="label label-error">未处理</span>
			    </c:if>
			    <c:if test="${batch.status eq 'finish'}">
			             <span class="label label-important">已处理</span>
			    </c:if>
			    <c:if test="${batch.status eq 'picking'}">
			            <span class="label label-success"> 已完成拣货</span>
			    </c:if>
			    </td>
			   <td>
			       <c:if test="${batch.status eq 'pending' }">
			       	  <a href="${ctx}/focusBatchTask/toCreateTask/${batch.batchTaskCode}" role="button"  class="btn btn-primary" >创建任务</a>
			       
			       </c:if>
			   </td>
			</tr>
		</c:forEach>
</c:when>
<c:otherwise>
<c:forEach items="${batchList}" var="batch" varStatus="i">
			<tr>
			  <td>${i.count}</td>
			  <td>${batch.warehouseCode}</td>
			  <td>${batch.batchTaskCode}</td>
			  <td>
			    <c:if test="${batch.type eq 'single'}">
			               单件
			    </c:if>
			     <c:if test="${batch.type eq 'multiple'}">
			               多件
			    </c:if>
			  </td>
			  
			  <td>${batch.ordenoQty}</td>
			  <td>${batch.username}</td>
			  <td>${batch.createDate}</td>
			  <td>
			    <c:if test="${batch.status eq 'pending'}">
			           <span class="label label-error">未处理</span>
			    </c:if>
			    <c:if test="${batch.status eq 'finish'}">
			             <span class="label label-important">已处理</span>
			    </c:if>
			    <c:if test="${batch.status eq 'picking'}">
			            <span class="label label-success"> 已完成拣货</span>
			    </c:if>
			    </td>
			   <td>
			       <c:if test="${batch.status eq 'pending' }">
			       	  <a href="${ctx}/focusBatchTask/toCreateTask/${batch.batchTaskCode}" role="button"  class="btn btn-primary" >创建任务</a>
			       
			       </c:if>
			   </td>
			</tr>
		</c:forEach>
</c:otherwise>
</c:choose>
		
		</tbody>
	</table>
<c:if test="${batchList eq null }">
   <tags:pagination page="${pageBatchList}" paginationSize="5" />
</c:if>
</body>
</html>
